﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Vehicle.Web.Pages.Cargo
{
    /// <summary>
    /// Copyright (C) M-Tear团队
    /// 文 件 名：Accept.aspx.cs
    /// 版    本：v1.00.0000
    /// 创建标识：2009-09-01   Created by 杨光远 V1.00.0000
    /// 功能说明：承运单接收页面类
    /// 注意事项：无
    /// 
    /// 更新记录：
    /// 
    /// </summary>
    public partial class Accept : Component.PageBase
    {

        #region ---基本变量实例化---
        Vehicle.BLL.Cargo b_Cargo = new Vehicle.BLL.Cargo();
        Vehicle.Model.ComponentsInfo m_ComponentsInfo = new Vehicle.Model.ComponentsInfo();
        public string onshow;//定义没有数据时页面的显示内容
        #endregion

        #region ---基本操作---
        /// <summary>
        /// 页面加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
              
                RepeaterDataBind();//绑定数据
            }
        }
        /// <summary>
        /// 绑定页面Repeater数据
        /// </summary>
        protected void RepeaterDataBind()
        {
            //如果选择为全部则选择值为0 通用实体层匹配条件为1 结果为1  Drop_Select.SelectedValue == "0" ? "1": Drop_Select.SelectedValue
            this.Anp_Page.RecordCount = b_Cargo.GetAllSearchCount(new Model.ComponentsInfo("Cargo", Drop_Select.SelectedValue == "0" ? "1" : "C_Receive", Drop_Select.SelectedValue == "0" ? "1" : Drop_Select.SelectedValue, "1", "1", "C_IsDelete", "1", "C_Time", Vehicle.Common.TextHelper.StringToDateTime((this.Gmdp_Start.DateString)), Vehicle.Common.TextHelper.StringToDateTime((this.Gmdp_End.DateString)), "C_ID"));//根据下拉菜单选择的进行数据绑定 
            m_ComponentsInfo.startIndex = Anp_Page.StartRecordIndex;//当前页的起始索引
            m_ComponentsInfo.endIndex = Anp_Page.EndRecordIndex;//当前页的结束索引
            m_ComponentsInfo.condition = Drop_Select.SelectedValue == "0" ? "1" : "C_Receive";//条件一
            m_ComponentsInfo.result = Drop_Select.SelectedValue == "0" ? "1" : Drop_Select.SelectedValue;//匹配结果一
            m_ComponentsInfo.Scondition = "C_IsDelete";//条件三
            m_ComponentsInfo.Sresult = "1";//匹配结果三
            if (Gmdp_Start.DateString != "")//判断起始时间是否为空
            {
                m_ComponentsInfo.StartTime = Vehicle.Common.TextHelper.StringToDateTime(this.Gmdp_Start.DateString);
            }
            if (Gmdp_End.DateString != "")//判断结束时间是否为空
            {
                m_ComponentsInfo.EndTime = Vehicle.Common.TextHelper.StringToDateTime(Gmdp_Start.DateString);
            }
            b_Cargo.RepeaterBind(ReptShow, m_ComponentsInfo);//绑定Repeater控件
            if (ReptShow.Items.Count == 0)//判断没有数据时页面的显示内容
            {
                onshow = "当前页面无数据";
            }
            else
            {
                onshow = "";
            }
        }
        /// <summary>
        /// 数据分页
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {

            RepeaterDataBind();

        }
        /// <summary>
        /// 根据下拉菜单选择数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Drop_Select_SelectedIndexChanged(object sender, EventArgs e)
        {
            RepeaterDataBind();
        }
        /// <summary>
        /// 根据时间选择数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btn_Select_Click(object sender, EventArgs e)
        {
            RepeaterDataBind();
        }

        /// <summary>
        /// Rept绑定数据事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ReptShow_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
           
                Label lab_C_Receive = (Label)e.Item.FindControl("lab_C_Receive");//更改接收情况
                switch (lab_C_Receive.Text)
                {
                    case "1": lab_C_Receive.Text = "是"; break;
                    case "2": lab_C_Receive.Text = "否"; break;
                    case "3": lab_C_Receive.Text = "审核中"; break;
                }
                Label lab_C_Result = (Label)e.Item.FindControl("lab_C_Result");//更改完成情况
                switch (lab_C_Result.Text)
                {
                    case "1": lab_C_Result.Text = "运输中"; break;
                    case "2": lab_C_Result.Text = "已完成"; break;
                    case "3": lab_C_Result.Text = "失败"; break;
                    case "4": lab_C_Result.Text = "审核中"; break;
                }
            }

        }
    
        #endregion
    }
}
